home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / program / swmp141.zip / PAS_SDK.ZIP / EXAMPLE2.PAS < prev    next >
Pascal/Delphi Source File  |  1995-12-12  |  3KB  |  98 lines

  1. PROGRAM Text_Mode_Player;
  2. {$M $1000,0,0}      {* Set heap size to zero !!! *}
  3.  
  4. USES    ModPlay,Crt;
  5.  
  6. VAR     Key:          CHAR;
  7.         Main_Volume:  BYTE;
  8.         Cursor_Shape: WORD;
  9.  
  10.  
  11. PROCEDURE Init_Cursor; ASSEMBLER;
  12. ASM
  13.   mov     ah,3
  14.   xor     bh,bh
  15.   int     10h
  16.   mov     [Cursor_Shape],cx
  17.   mov     ah,1
  18.   mov     cx,2020h
  19.   int     10h
  20. end;
  21.  
  22. PROCEDURE Restore_Cursor; ASSEMBLER;
  23. ASM
  24.   mov     ah,1
  25.   mov     cx,[Cursor_Shape]
  26.   int     10h
  27. END;
  28.  
  29. PROCEDURE Update_Screen;
  30. VAR     i,j:     INTEGER;
  31.         Bar:     STRING[32];
  32.         SongPos: WORD;
  33.  
  34. BEGIN
  35.   GotoXY(1,7);
  36.   Mod_Peak;
  37.   FOR i:=1 TO Channels DO
  38.   BEGIN
  39.     Bar:='░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░';
  40.     IF Peak[i]>1 THEN FOR j:=1 TO (Peak[i] SHR 1) DO Bar[j]:='▓';
  41.     GotoXY(2,3+i); Write(Bar);
  42.   END;
  43.   SongPos:=Mod_Position;
  44.   GotoXY(3,6+Channels); Write('Playing pattern #',SongPos SHR 8,', line #',SongPos AND $FF,' ');
  45.   GotoXY(62,WhereY); Write('Main volume: ',Main_Volume*100 div 64:3,'%');
  46. END;
  47.  
  48.  
  49. BEGIN
  50.   Mod_Init(Detection,0,0,0);
  51.   IF Soundcard<>0 THEN
  52.   BEGIN
  53.     Mod_Load('atomic2.mod');
  54.     IF (Channels<>0) THEN
  55.     BEGIN
  56.       Init_Cursor;
  57.       Main_Volume:=58;
  58.       Mod_Volume(Main_Volume);
  59.       Mod_Play(0);
  60.       TextColor(WHITE); TextBackground(BLACK);
  61.       ClrScr;
  62.       TextBackground(BLUE); GotoXY(1,1); ClrEol;
  63.       GotoXY(20,1); Write('SOUND WIZARDS MODULE PLAYER PASCAL DEMO');
  64.       GotoXY(1,6+Channels); ClrEol;
  65.       TextBackground(BLACK);
  66.       GotoXY(36,1+Channels); Write('Press       up,down:     to adjust volume  ');
  67.       GotoXY(36,2+Channels); Write('            left,right:  to change position');
  68.       GotoXY(36,3+Channels); Write('or escape to quit this little program......');
  69.       TextBackground(BLUE);
  70.       REPEAT
  71.     Update_Screen;
  72.     Key:=' ';
  73.     IF KeyPressed THEN Key:=ReadKey;
  74.     IF Key=chr(0) THEN
  75.     BEGIN
  76.       Key:=ReadKey;
  77.       CASE Key OF
  78.         chr($48):  IF Main_Volume < 64 THEN
  79.                BEGIN
  80.              Main_Volume:=Main_Volume+2;
  81.              Mod_Volume(Main_Volume);
  82.                        END;
  83.             chr($50):  IF Main_Volume > 0 THEN
  84.                        BEGIN
  85.                          Main_Volume:=Main_Volume-2;
  86.                          Mod_Volume(Main_Volume);
  87.                        END;
  88.             chr($4D):  Mod_Forward;
  89.             chr($4B):  Mod_Rewind;
  90.           END;
  91.         END;
  92.       UNTIL((Mod_Status=0) OR (Key=Chr(27)));
  93.       GotoXY(1,9+Channels);
  94.       Restore_Cursor;
  95.     END ELSE WriteLn('Could not load song ATOMIC2.MOD...');
  96.   END ELSE WriteLn('Could not initialize hardware...');
  97. END.
  98.